package com.gwq.computed;

import com.gwq.utils.DateUtils;

import java.io.*;

public class BinaryOperationBaseTester {

    public static void main(String[] args) throws IOException {
//        OperationBase operationBase = new OperationBase();
//        AdditionOperation[][] base = operationBase.produceAdditionBase();
//        operationBase.displayBase(base);

//        SubstractBase operationBase = new SubstractBase();
//        SubstractOperation[][] base = operationBase.produceSubtionBase();
//        operationBase.displayBase(base);


        OperationBase operationBase = new OperationBase();
        Exercise2 op = operationBase.generateAdditionExercise(50);
        formattedDisplay(op,5);

//        OperationBase operationBase = new OperationBase();
//        Exercise2  exercise2 = operationBase.generateAdditionExercise(50);




        /*File file = new File(DateUtils.getYyyyMMddHHmmss()+".txt");
        if (file.exists()) {
            System.out.println("文件存在");
        } else {
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
            System.out.println("文件创建成功");
        }
        //将list写入文件
        Writer out = new FileWriter(file);
        BufferedWriter bw= new BufferedWriter(out);


        int i=0;
        bw.write("\t\t\t---  请完成以下算式   ---");
        while (exercise2.hasNext()){
            if(i++ % 5==0){
                bw.newLine();
            }
            bw.write(exercise2.next().asString()+"\t;"+"\t\t");
        }

        bw.newLine();
        bw.flush();
        bw.close();*/


//        formattedDisplay(exercise2,5);
    }

    //打印
    private static void formattedDisplay(Exercise2 exercise2,int columns){
        int i=0;
        while (exercise2.hasNext()){
            if(i++ % columns==0){
                System.out.println();
            }
            System.out.print(exercise2.next().asString()+"\t\t");
        }
    }
}
